package org.flik.client.main;

import org.flik.client.shared.ClientUtils;
import org.flik.server.dto.TicketDetailComment;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class TicketDetailComments extends Composite {

	private static TicketCommentUiBinder uiBinder = GWT.create(TicketCommentUiBinder.class);

	@UiField Label comment, postedBy, postedDate;
	
	interface TicketCommentUiBinder extends UiBinder<Widget, TicketDetailComments> {
	}

	public TicketDetailComments(TicketDetailComment ticketComment) {
		initWidget(uiBinder.createAndBindUi(this));
		mapDataToWidgets(ticketComment);
	}

	private void mapDataToWidgets(TicketDetailComment ticketComment){
		comment.setText(ticketComment.getComment());
		postedBy.setText(ticketComment.getPostedBy());	
		postedDate.setText(ClientUtils.DTF_GENERAL_DISPLAY.format(ticketComment.getPostedOn()));
	}
}
